import { defineStore } from "pinia";
//pinia仓库写法：组合式API，选择式API写法
import { reqHospitalDetail, reqHospitalDepartment } from "@/api/hospital/index";
const useDetailStore = defineStore("Detail", {
  state: () => {
    return {
      //医院详情的数据
      hospitalInfo: {},
      //存储医院科室的数组
      departmentArr: [],
    };
  },
  actions: {
    //获取医院详情的方法
    async getHospital(hoscode: string) {
      let result = await reqHospitalDetail(hoscode);
      if (result.data.code === 200) {
        this.hospitalInfo = result.data.data;
      }
    },
    //获取某一个医院科室的数据
    async getDepartment(hoscode: string) {
      let result = await reqHospitalDepartment(hoscode);
      if (result.data.code === 200) {
        this.departmentArr = result.data.data;
      }
    },
  },
  getters: {},
});
export default useDetailStore;
